package com.baturu.vin.honda.transformer;

import com.baturu.kit.kit.function.SafeFunction;
import com.baturu.vin.dto.EPCPartsImageDTO;
import com.baturu.vin.dto.superEPC.SEPCGroupDTO;
import com.baturu.vin.honda.dto.SEPCHondaSubGroupDTO;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;

/**
 * @Author: chenjiahao
 * @Time: 2019/5/8
 */
public class SEPCGroupTransformer {
    public static final SafeFunction<SEPCHondaSubGroupDTO, SEPCGroupDTO> SUB_GROUP_TO_SEPC_SUB_GROUP =
            input -> {
                SEPCGroupDTO build = SEPCGroupDTO.builder()
                        .mainGroup(input.getMainGroup())
                        .mainGroupCode(input.getNplgrp())
                        .subGroup(input.getNplblkedit() + " " + input.getXplblk())
                        .subGroupCode(input.getNplblk())
                        .imageUrl(input.getImageUrl())
                        .epcPartsImageDTOList(input.getEpcPartsImageDTOList())
                        .build();
                EPCPartsImageDTO epcPartsImageDTO = new EPCPartsImageDTO();
                epcPartsImageDTO.setImageCode(input.getNplblk());
                if (CollectionUtils.isEmpty(input.getEpcPartsImageDTOList())) {
                    build.setEpcPartsImageDTOList(Lists.newArrayList(epcPartsImageDTO));
                }
                return build;
            };

}
